5.2 - Design - Observations for Spatial Awareness
To transition from abstract economic management to concrete combat micro-management, we must fundamentally redesign our agent's perception. The observation space must now encode spatial and temporal relationships between units on the battlefield.
Perceptual Requirements for Kiting
To successfully learn the kiting policy, the agent must be able to perceive the answers to these questions on every decision step:
- My Condition: How damaged am I?
- My Weapon State: Is my weapon ready to fire right now?
- Enemy Condition: How damaged is my target?
- Relative Position: Am I too close or too far from the enemy?
- Engagement Feasibility: Is the enemy currently within my attack range?
This checklist directly informs the design of our observation vector.
Observation Space Specification
We will provide the agent with a fixed-size, 1D vector (numpy.ndarray
) that contains all the necessary information for the 1v1 kiting task.
- Gymnasium Type:
gymnasium.spaces.Box
- Shape:
(5,)
- Data Type:
numpy.float32
Index | Feature Description | Source python-sc2 Property | Rationale / Question Answered |
---|---|---|---|
Agent's Internal State | |||
0 | Agent's Health % | marine.health_percentage | "What is my current level of risk?" |
1 | Weapon Cooldown | 1.0 if marine.weapon_cooldown > 0 else 0.0 | (Temporal) "Is my primary weapon available?" |
Target's Internal State | |||
2 | Target's Health % | zergling.health_percentage | "How close am I to neutralizing the threat?" |
Relational State | |||
3 | Distance to Target | marine.distance_to(zergling) (Normalized) | (Spatial) "Is my positioning correct?" |
4 | Target in Range | 1.0 if marine.target_in_range(zergling) else 0.0 | (Spatial) "Is attacking a valid move from this position?" |
Design Rationale- Flattened Feature Vector
For this constrained 1v1 scenario, we are using a flattened feature vector. This is a simple and effective representation because the relationships are fixed: the state always describes "me" in relation to "the single enemy."
This approach has limitations and does not scale to more complex scenarios (e.g., a 5v5 battle). A more advanced agent would require a relational representation (such as a list of unit vectors or a graph neural network) to handle a variable number of units and their interactions.
However, for this foundational combat task, the minimalist 5-feature vector is the correct design choice. It provides all necessary information while keeping the state space small and highly learnable, allowing the agent to focus solely on mastering the core mechanics of timing and spacing.